CANDIR:=../rtl/peripherals/can/
CANTBDIR:=../testbench/can_testbench.v
CANMODULE:=can_testbench
CANDO:=./CAN_do/can_tx_wave.do

I2CDIR:=../rtl/peripherals/i2c/
I2CTBDIR:=../testbench/i2c_bench_top.v ../testbench/i2c_slave_model.v
I2CMODULE:=i2c_bench_top
I2CDO:=./i2c_wave.do

PWMDIR:=../rtl/peripherals/pwm/
PWMTBDIR:=../testbench/pwm_tb.v
PWMMODULE:=pwmbus_tb
PWMDO:=./pwm_wave.do

SPIDIR:=../rtl/peripherals/spi/
SPITBDIR:=../testbench/spi_bench_top.v ../testbench/spi_slave_model.v 
SPIMODULE:=spi_testbench
SPIDO:=./spi_wave.do

UARTDIR:=../rtl/peripherals/uart/
UARTTBDIR:=../testbench/uart_testbench.v
UARTMODULE:=uart_tb
UARTDO:=./uart_wave.do

DEFDIR:=../defines/

SRCS:=$(wildcard $(I2CDIR)*.v) $(I2CTBDIR)

COMPILE:=vlog -incr +incdir+$(DEFDIR)
SIM:=vsim -novopt -do 

top:
	./top_msim.scr -c

gui::
	./top_msim.scr

start::
	vlib work && vmap work work

mcu::
	./mcu_msim.scr

uart::
	$(COMPILE) $(wildcard $(UARTDIR)*.v) $(UARTTBDIR)
	$(SIM) "do $(UARTDO);run -all;" $(UARTMODULE)


pwm::
	$(COMPILE) $(wildcard $(PWMDIR)*.v) $(PWMTBDIR)
	$(SIM) "do $(PWMDO);run -all;" $(PWMMODULE)

can::
	$(COMPILE) $(wildcard $(CANDIR)*.v) $(CANTBDIR)
	$(SIM) "do $(CANDO);run -all;" $(CANMODULE)


i2c::
	$(COMPILE) $(wildcard $(I2CDIR)*.v) $(I2CTBDIR)
	$(SIM) "do $(I2CDO);run -all;" $(I2CMODULE)

spi::
	$(COMPILE) $(wildcard $(SPIDIR)*.v) $(SPITBDIR)
	$(SIM) "do $(SPIDO);run -all;" $(SPIMODULE)

		
clean::
	rm -rf *.wlf transcript modelsim.ini  work/
